﻿@model IList<Nop.Web.Models.Customer.CustomerAttributeModel>
@using Nop.Core.Domain.Catalog;
@foreach (var attribute in Model)
{
    string controlId = string.Format("customer_attribute_{0}", attribute.Id);
    string textPrompt = attribute.Name;

    <div class="inputs">
        <label>@textPrompt:</label>
        
        @switch (attribute.AttributeControlType)
        {
            case AttributeControlType.DropdownList:
            {
            <select name="@(controlId)" id="@(controlId)">
                @if (!attribute.IsRequired)
                    {
                    <option value="0">---</option>
                    }
                @foreach (var caValue in attribute.Values)
                    {
                    <option selected="@caValue.IsPreSelected" value="@caValue.Id">@caValue.Name</option>
                    }
            </select>
            }
                break;
            case AttributeControlType.RadioList:
            {
            <ul class="option-list">
                @foreach (var caValue in attribute.Values)
                    {
                    <li>
                        <input id="@(controlId)_@(caValue.Id)" type="radio" name="@(controlId)" value="@caValue.Id" checked="@caValue.IsPreSelected" />
                        <label for="@(controlId)_@(caValue.Id)">@caValue.Name</label>
                    </li>
                    }
            </ul>
            }
                break;
            case AttributeControlType.Checkboxes:
            {
            <ul class="option-list">
                @foreach (var caValue in attribute.Values)
                    {
                    <li>
                        <input id="@(controlId)_@(caValue.Id)" type="checkbox" name="@(controlId)" value="@caValue.Id" checked="@caValue.IsPreSelected" />
                        <label for="@(controlId)_@(caValue.Id)">@caValue.Name</label>
                    </li>
                    }
            </ul>
            }
                break;
            case AttributeControlType.TextBox:
            {
            <input name="@(controlId)" type="text" class="textbox" id="@(controlId)" @(!String.IsNullOrWhiteSpace(attribute.DefaultValue) ? " value=" + attribute.DefaultValue : null) />
            }
                break;
            case AttributeControlType.MultilineTextbox:
            {
            <textarea id="@(controlId)" name="@(controlId)">@(!String.IsNullOrWhiteSpace(attribute.DefaultValue) ? attribute.DefaultValue : null)</textarea>
            }
                break;
            case AttributeControlType.Datepicker:
            case AttributeControlType.FileUpload:
            case AttributeControlType.ColorSquares:
            {
                //not support attribute type
            }
                break;
        }
        @if (attribute.IsRequired)
        {
            @Html.RequiredHint()
        }
    </div>
}
